package com.smedi.ismedi.web.starter.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;

import java.util.concurrent.Executor;

/**
 * 解决异步过程中会出现的 ticket 丢失问题
 */
@Slf4j
@Configuration
public class AsyncForwardConfig extends AsyncConfigurerSupport {


    private final Executor contextAwarePoolExecutor;

    public AsyncForwardConfig(@Qualifier(value = AsyncThreadPoolConfig.asyncThreadName)Executor contextAwarePoolExecutor) {
        this.contextAwarePoolExecutor = contextAwarePoolExecutor;
    }

    @Override
    public Executor getAsyncExecutor() {
        log.info("装配异步身份验证");
        return contextAwarePoolExecutor;
    }

//    @Bean
//    public ContextAwarePoolExecutor contextAwarePoolExecutor() {
//        return new ContextAwarePoolExecutor();
//    }

}